package com.study.shiro.jwt;

import io.vertx.core.json.JsonObject;
import io.vertx.ext.jwt.JWK;
import io.vertx.ext.jwt.JWT;
import io.vertx.ext.jwt.JWTOptions;

/**
 * @author: chenhs
 * @date: Created in 6:33 2020/3/6
 **/
public class JWKTest {


    public static void main(String[] args) {

        JWKTest jwk = new JWKTest();
        jwk.generateToken();


//        String str = "614779fa4ac54263913f002199ef3bc2";
//        System.out.println(str.length());

    }


    public String generateToken() {
        String algorithm = "HS512";
        String hmac = "abc";
        JWK jwk = new JWK(algorithm, hmac);
        JWT jwt = new JWT().addJWK(jwk);

        JsonObject payload = new JsonObject();
        payload.put("appid", "appid");

        JWTOptions options = new JWTOptions();
        options.setAlgorithm(algorithm);
        options.setSubject("1994");
        options.setIssuer("Member");
        options.setExpiresInSeconds(5);
        String idToken = jwt.sign(payload, options);

        System.out.println(idToken);
        System.out.println(idToken.length());

        return idToken;
    }

}
